﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Ruandao.HostServer
{
    /// <summary>
    /// 其中有一个获取实例的静态方法，该方法使用配置信息创建出一个HostServerContext的子类实例。
    /// </summary>
    abstract public class HostServerContext
    {
        public static HostServerContext Instance = CreateInstance();

        static private HostServerContext CreateInstance()
        {
            string provider = ConfigurationManager.AppSettings["HostServerProvider"];
            if( string.IsNullOrEmpty(provider ) ) provider = "FixedProvider";
            switch (provider)
            {
                case "FixedProvider":
                    return new FixedHostServerContext();
                //case "JsonProvider":
                //    return new JsonHostServerContext();
                //case "SqlServerProvider":
                //    return new SqlHostServerContext();
            }
            return new FixedHostServerContext();
        }

        /// <summary>
        ///  获取当前的网件对象，网件实例由网件应用的特定网站来实例化。
        /// </summary>
        /// <returns></returns>
        abstract internal SiteWare GetCurrentSiteWare();

    }
}
